/*封装http请求*/
const HOST = 'http://www.daguanjia.com/',
// const HOST = 'http://admin.cypto.cn/',
  DEBUG = '?XDEBUG_SESSION_START=14403',
  API = {
    postVertCode: HOST + 'api/user/verification_code/send' + DEBUG,
    postRegister: HOST + 'api/user/public/register' + DEBUG,
    postLogin: HOST + 'api/user/public/login',
    getHavePassword: HOST + 'api/user/profile/havePassword' + DEBUG,
    postAddPassword: HOST + 'api/user/profile/addPassword' + DEBUG,
    getReadPerson: HOST + 'api/user/profile/readPerson' + DEBUG,
    postEditPerson: HOST + 'api/user/profile/editPerson' + DEBUG,
    postAddTask: HOST + 'api/portal/task/addTask' + DEBUG,
    postAddTaskP: HOST + 'api/user/profile/addTask',
    getReadTasks: HOST + 'api/user/profile/indexTask' + DEBUG,
    getReadTasksHall: HOST + 'api/portal/task/indexTaskHall',
    getReadTask: HOST + 'api/user/profile/readTask' + DEBUG,
    // postAddAvatar: HOST + 'api/user/image/addAvatar' + DEBUG,
    postAddAvatar: HOST + 'api/user/image/uploadImg' + DEBUG,
    postUploadImg: HOST + 'api/user/upload/image' + DEBUG,
    getMyOrder: HOST + 'api/portal/order/myOrder' + DEBUG,
    postAddOrder: HOST + 'api/portal/order/addOrder' + DEBUG,
    postTaskStart: HOST + 'api/portal/task/taskStart' + DEBUG,
    postTaskEnd: HOST + 'api/portal/task/taskEnd' + DEBUG,
    postDoPay: HOST + 'api/portal/pay/doPay' + DEBUG,
    postWechatPay: HOST + 'api/portal/pay/wechatPay' + DEBUG,
    postAddOffer: HOST + 'api/portal/offer/addOffer' + DEBUG,
    getReadOffers: HOST + 'api/portal/offer/indexOffer' + DEBUG,
    getReadOffersHall: HOST + 'api/portal/offer/indexOfferHall',
    getReadOffer: HOST + 'api/portal/offer/readOffer' + DEBUG,
    postAddOfferOrder: HOST + 'api/portal/offer_order/addOfferOrder' + DEBUG,
    getMyOfferOrder: HOST + 'api/portal/offer_order/myOfferOrder' + DEBUG,
    postOfferStart: HOST + 'api/portal/offer/offerStart' + DEBUG,
    postOfferEnd: HOST + 'api/portal/offer/offerEnd' + DEBUG,
    // postImageUpload: HOST + 'api/user/upload/one' + DEBUG,
    postImageUpload: HOST + 'api/portal/task/imageUpload/dir/task' + DEBUG,
    postZizhiImage: HOST + 'api/user/user/zizhiImage/dir/zizhi' + DEBUG,
    postIdentityImage: HOST + 'api/user/user/identityImage/dir/identity' + DEBUG,
    // getVerifyOrder: HOST + 'api/portal/pay/verifyOrder' + DEBUG,
    getVerifyOrder: HOST + 'api/user/pay_return/verifyOrder' + DEBUG,
    postVerifyToken: HOST + 'api/portal/user/verifyToken' + DEBUG,
    getPayInfo: HOST + 'api/portal/pay/payInfo' + DEBUG,
    getOfferPayInfo: HOST + 'api/portal/pay/offerPayInfo' + DEBUG,
    postBuildVIP: HOST + 'api/portal/user/buildVIP' + DEBUG,
    getVipInfo: HOST + 'api/portal/user/vipInfo' + DEBUG,
  };

(function($, owner) {
  http.stat = 666;

  http.get = function(reqUrl, reqData = {}, sucCallback = $.noop, faiCallback = $.noop) {
    $.ajax(reqUrl, {
      data: reqData,
      success: sucCallback,
      error: faiCallback
    });
  }

  http.post = function(reqUrl, reqData = {}, sucCallback = $.noop, faiCallback = $.noop) {
    $.ajax(reqUrl, {
      type: 'post',
      data: reqData,
      success: sucCallback,
      error: faiCallback
    });
  }

  http.getToken = function(options) {
    $.ajax(options.url, {
      data: options.data,
      headers: { 'XX-Token': options.token, 'XX-Device-Type': options.deviceType },
      success: options.success,
      error: options.error
    });
  }

  http.postToken = function(options) {
    $.ajax(options.url, {
      data: options.data,
      type: 'post',
      headers: { 'XX-Token': options.token, 'XX-Device-Type': options.deviceType },
      success: options.success,
      error: options.error
    });
  }
})(mui, http = {})

/*
  options = {
    url: '',
    data: {},
    token: '',
    deviceType: '',
    success: function() {},
    error: function() {}
  }
 */